package org.ascollada.core
{
	import flash.events.EventDispatcher;
	
	import org.ascollada.ASCollada;
	import org.ascollada.core.log.DaeLogger;

	public class DaeDocument extends EventDispatcher
	{
		default xml namespace = new Namespace( ASCollada.DAE_SCHEMA_LOCATION );

		/** */
		public var geometries		:Object;
		
		/** */
		public var visual_scenes	:Object;
		
		/**
		 * 
		 */ 
		public function DaeDocument()
		{
			
		}
		
		/**
		 * 
		 */ 
		public function read( colladaXML:XML ) : void
		{
			readGeometries( colladaXML );
			readVisualScenes( colladaXML );
		}
		
		/**
		 * 
		 */ 
		public function readGeometries( colladaXML:XML ) : void
		{
			this.geometries = new Object();
			
			var list : XMLList = colladaXML..geometry;
			
			for ( var i:int = 0; i < list.length(); i++ )
			{
				var geometry : DaeGeometry = new DaeGeometry( this, list[i] );
				
				this.geometries[ geometry.id ] = geometry;
			}
		}
		
		/**
		 * 
		 */ 
		public function readVisualScenes( colladaXML:XML ):void
		{
			this.visual_scenes = new Object();
			
			var list : XMLList = colladaXML..visual_scene;
			
			for ( var i:int = 0; i < list.length(); i++ )
			{
				var vscene : DaeVisualScene = new DaeVisualScene( this, list[i] );
				
				this.visual_scenes[ vscene.id ] = vscene;
			}
		}
	}
}